﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.IO.MemoryMappedFiles;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using SkiaSharp;

namespace Test_保存;

public class Class1
{
    [Test]
    public void Linq()
    {
        var people = new List<Person>
        {
            new("Alice", 30, 1),
            new("Bob", 25, 2),
            new("Alice", 28,3),
            new("Charlie", 35, 7),
            new("Bob", 22, 5),
            new("David", 30, 6)
        };


        var dictionary = people.GroupBy(person => person.Name)
            .OrderBy(group => people.IndexOf(group.First()))
            .ToDictionary(
                persons => persons.Key,
                group => group.ToList() // 映射到匿名类型
            );


        
    
        
        
    }

    [Test]
    public void Stream()
    {
        string filePath = "data.bin";
        using (FileStream fileStream = new FileStream(filePath, FileMode.Create))
        using (BinaryWriter writer = new BinaryWriter(fileStream))
        {
            writer.Write(12345); // 直接写入整数
            writer.Write("Hello, World!"); // 写入字符串
        }
        

    }
}

public class Person
{
 
    public int Id { get; set; }
    public string Name { get; set; }

    public int Age { get; set; }

    public Person(string name, int age, int id)
    {
        Name = name;
        Age = age;
        Id = id;
    }

    public override string ToString()
    {
        return "person" + Id;
    }
}